function [pendiente]=direccion_palabra(downbaseline,ancho_cuerpo,xbin)
[m,n]=size(xbin);
valores=ones(m,n);
for s=1:n
    clear f c
    [f,c]=find(xbin(:,s)==0);
    if isempty(f)==0
        v=(downbaseline-(ancho_cuerpo/2));
        [f1,c]=find(f>v);
        valor=max(f(f1));
        valores(valor,s)=0;         
    end
end
clear valor
[f,c]=find(valores==0);
%extremos
f1=f(1);
c1=c(1);
f2=f(end);
c2=c(end);
f1=abs(f1-m);
f2=abs(f2-m);
pendiente=((f2-f1)/(c2-c1));
%figure;
%hold on
%imshow(valores);

valor=round(length(c)/3);
pendientes=[];
s=1+valor;
while s<=length(c)
    if (s)<length(c)
        f11=f(s);
        c11=c(s);
        f11=abs(f11-m);
        pendientes=[pendientes ((f11-f1)/(c11-c1))];
        %line([c1 c11],[abs(f1-m) abs(f11-m)],'Color','r','LineWidth',2);
        f1=f11;
        c1=c11;
    elseif ((s+valor)>length(c))&(c11<c2)
        pendientes=[pendientes ((f11-f2)/(c11-c2))];
        %line([c11 c2],[abs(f1-m) abs(f2-m)],'Color','r','LineWidth',2);
    end
    s=s+valor;
    
end
%hold off

pendiente=mean(pendientes);